import logging
from flask import session
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from info import create_app, db

app = create_app("development")
# class Config(object):
#     """工程配置信息"""
#     SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"
#     DEBUG = True
#
#     # 数据库的配置信息
#     SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information_news"
#     SQLALCHEMY_TRACK_MODIFICATIONS = False
#     # redis配置
#     REDIS_HOST = "127.0.0.1"
#     REDIS_PORT = 6379
#
#     # flask_session的配置信息
#     SESSION_TYPE = "redis"  # 指定 session 保存到 redis 中
#     SESSION_USE_SIGNER = True  # 让 cookie 中的 session_id 被加密签名处理
#     SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)  # 使用 redis 的实例
#     PERMANENT_SESSION_LIFETIME = 86400  # session 的有效期，单位是秒

# 配置

manager = Manager(app)
Migrate(app, db)
manager.add_command('db', MigrateCommand)


@app.route("/")
def index():
    session["name"] = "UMU689"
    logging.debug("测试debug")
    logging.warning("测试warning")
    logging.error("测试error")
    logging.fatal("测试fatal")
    return "success!%s" % session["name"]


if __name__ == '__main__':
    manager.run()
